//
//  CircleModel.m
//  Lucky28
//
//  Created by zr on 2018/8/6.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "CircleModel.h"

@implementation CircleModel


+(instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    CircleModel *model =[[CircleModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}


+(void)circleWithEssence:(NSString *)essence WithSucess:(void (^)(NSArray<CircleModel *> *))sucessBlock error:(void (^)(void))errorBlock{
    
    NSDictionary * parameters = @{@"pageno":@"1",@"pagesize":@"50",@"note_type":@"4",@"is_essence":essence};
    
    [[NetworkTool sharedTools] POST:@"/index/Note/noteList" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        NSArray * paramArray = responseObject[@"data"];
        
//        NSLog(@"==%@",paramArray);
        
        NSMutableArray *mArray = [NSMutableArray array];
        
        [paramArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            CircleModel * model = [CircleModel modelWithDictionary:obj];
            
            [mArray addObject:model];
            
        }];
        
        if(sucessBlock){
            sucessBlock(mArray.copy);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}


- (void)setValue:(id)value forKey:(NSString *)key{
    
    if ([key isEqualToString:@"id"]) {
        
        self.ID = value;
    }else{
        
        [super setValue:value forKey:key];
    }
    
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
}

@end
